package demo2;

public class Main {
    public static void main(String[] args) {
        Person xc = new Person("小菜");
        System.out.println("装扮如下");
        TShirt tShirt = new TShirt();
        BigTrouser bigTrouser = new BigTrouser();
        Shoes shoes = new Shoes();

        tShirt.Decorate(xc);
        bigTrouser.Decorate(tShirt);
        shoes.Decorate(bigTrouser);

        shoes.show();
    }
}
class Person{
    private String name ;
    public Person(String name){
        this.name = name;
    }
    public Person(){

    }
    public void show(){
        System.out.println("装扮的 " + name);
    }
}

//服装类 Decorator
class Finery extends Person{
    protected Person component;

    public void Decorate(Person component){
        this.component = component;
    }

    @Override
    public void show() {
        if(component != null){
            component.show();
        }
    }
}

//具体的服装类
class TShirt extends Finery{
    @Override
    public void show() {
        System.out.println("大T恤");
        super.show();
    }
}

class BigTrouser extends Finery{
    @Override
    public void show(){
        System.out.println("跨库");
        super.show();
    }
}
class Shoes extends Finery{
    @Override
    public void show(){
        System.out.println("皮鞋");
        super.show();
    }
}